﻿@model Zippy.Data.Collections.PaginatedList<Z30CRM.Entity.Z30Communication>
@using Z30CRM.Entity
@using Z30CRM.Entity.Helper
@using Z01Beetle.Entity;
@{
	ViewBag.Title = "沟通记录";
	Layout = "~/Views/Shared/_Layout.cshtml";
	Zippy.Data.IDalProvider db = ViewBag.db as Zippy.Data.IDalProvider;
}
<script type="text/javascript">
		var pageSize = @ViewBag.PageSize;
		var controller = "/Z30Communication";
		var sortUrl = "@Html.Raw(Model.ToSortUrl())";

		$(function () {
			$("#bQuery").click(function () {
				window.location.href = controller + '/?PageSize=' + pageSize 
										+ "&qContent=" + encodeURIComponent($("#qContent").val())
										+ "&qWish=" + encodeURIComponent($("#qWish").val())
										+ "&qSuccessRatio=" + encodeURIComponent($("#qSuccessRatio").val())
										+ "&qCreateDateStart=" + encodeURIComponent($("#qCreateDateStart").val())
										+ "&qCreateDateEnd=" + encodeURIComponent($("#qCreateDateEnd").val())
;
										
			});
		});
</script>
<script type="text/javascript" src="/content/scripts/pagemvc.js"></script>
<div id="contents">
	<div id="top">
		<div class="con clearfix">
			<div class="fl">
				@Html.Raw(ViewBag.TopMenu)
			</div>
			<div class="pop-box pop-query w600" rel="search">
				<div class="con">
					<a rel="close" class="close mr10" href="javascript:;">关闭</a>
					<div class="msg-box msg-contents">
						<table class="query">
							<tr>
								<td class='tt'>
									沟通内容：
								</td>
								<td class='tc'>
									<input type='text' class='text' id='qContent' />
								</td>
								<td class='tt'>
									创建时间：
								</td>
								<td class='tc'>
									<input type='text' class='text' id='qCreateDateStart' />
									-
									<input type='text' class='text' id='qCreateDateEnd' />
								</td>
								<td>
								</td>
							</tr>
							<tr>
								<td class='tt'>
									客户意向：
								</td>
								<td class='tc'>
									<input type='text' class='text' id='qWish' />
								</td>
								<td class='tt'>
									成功概率：
								</td>
								<td class='tc'>
									<input type='text' class='text' id='qSuccessRatio' />
								</td>
								<td>
								</td>
							</tr>
						</table>
					</div>
					<div class="bottom">
						<a class="jenter button" href="javascript:;" id='bShowAll'>显示全部<b></b></a> <a class="jenter button active"
							href="javascript:;" id='bQuery'>查询<b></b></a>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div id="main">
		@{
			var orCol = Request["orderCol"];
			int iorCol = orCol.ToInt32();
		}
		<table cellspacing="0" cellpadding="0" border="0" rel="main" class="list-table">
			<tr rel="title">
				<th width="20">
					<input type="checkbox" rel="check">
				</th>
				<th>
					客户
					@if (iorCol == 3)
					{
						<i title="点击排序" class="icon i_sort i_asc" rel="4"></i>
					}
					else if (iorCol == 4)
					{ 
						<i title="点击排序" class="icon i_sort i_desc" rel="3"></i>
					}
					else
					{ 
						<i title="点击排序" class="icon i_sort i_nosort" rel="3"></i>
					}
				</th>
				<th>
					拜访方式
					@if (iorCol == 5)
					{
						<i title="点击排序" class="icon i_sort i_asc" rel="6"></i>
					}
					else if (iorCol == 6)
					{ 
						<i title="点击排序" class="icon i_sort i_desc" rel="5"></i>
					}
					else
					{ 
						<i title="点击排序" class="icon i_sort i_nosort" rel="5"></i>
					}
				</th>
				<th>
					成功概率
					@if (iorCol == 11)
					{
						<i title="点击排序" class="icon i_sort i_asc" rel="12"></i>
					}
					else if (iorCol == 12)
					{ 
						<i title="点击排序" class="icon i_sort i_desc" rel="11"></i>
					}
					else
					{ 
						<i title="点击排序" class="icon i_sort i_nosort" rel="11"></i>
					}
				</th>
				<th>
					客户意向
					@if (iorCol == 7)
					{
						<i title="点击排序" class="icon i_sort i_asc" rel="8"></i>
					}
					else if (iorCol == 8)
					{ 
						<i title="点击排序" class="icon i_sort i_desc" rel="7"></i>
					}
					else
					{ 
						<i title="点击排序" class="icon i_sort i_nosort" rel="7"></i>
					}
				</th>
				<th>
					下次拜访提醒日期
					@if (iorCol == 9)
					{
						<i title="点击排序" class="icon i_sort i_asc" rel="10"></i>
					}
					else if (iorCol == 10)
					{ 
						<i title="点击排序" class="icon i_sort i_desc" rel="9"></i>
					}
					else
					{ 
						<i title="点击排序" class="icon i_sort i_nosort" rel="9"></i>
					}
				</th>
				<th>
					沟通日期
					@if (iorCol == 13)
					{
						<i title="点击排序" class="icon i_sort i_asc" rel="14"></i>
					}
					else if (iorCol == 14)
					{ 
						<i title="点击排序" class="icon i_sort i_desc" rel="13"></i>
					}
					else
					{ 
						<i title="点击排序" class="icon i_sort i_nosort" rel="13"></i>
					}
				</th>
				<th>
					持续时间
					@if (iorCol == 15)
					{
						<i title="点击排序" class="icon i_sort i_asc" rel="16"></i>
					}
					else if (iorCol == 16)
					{ 
						<i title="点击排序" class="icon i_sort i_desc" rel="15"></i>
					}
					else
					{ 
						<i title="点击排序" class="icon i_sort i_nosort" rel="15"></i>
					}
				</th>
				<th>
					创建时间
					@if (iorCol == 17)
					{
						<i title="点击排序" class="icon i_sort i_asc" rel="18"></i>
					}
					else if (iorCol == 18)
					{ 
						<i title="点击排序" class="icon i_sort i_desc" rel="17"></i>
					}
					else
					{ 
						<i title="点击排序" class="icon i_sort i_nosort" rel="17"></i>
					}
				</th>
				<th>
					操作
				</th>
			</tr>
			@if (Model.Count > 0)
			{
				foreach (var item in Model)
				{
				<tr rel="item">
					<td class="tc">
						<input type="checkbox" value="@item.CommunicationID" name='checkID' class="xID" />
					</td>
					<td>
						@{
					var title = db.FindUnique<Z01Customer>("CustomerID=" + item.CustomerID, "Title");
						}
						@title
					</td>
					<td>
						@typeof(EAP.Logic.Z30.VisitWays).ToStringUnique(item.VisitWay ?? 0, typeof(Resources.X))
					</td>
					<td>
						@typeof(EAP.Logic.Z30.SuccessRatioes).ToStringUnique(item.SuccessRatio ?? 0, typeof(Resources.X))
					</td>
					<td>
						@typeof(EAP.Logic.Z30.Wishs).ToStringUnique(item.Wish ?? 0, typeof(Resources.X))
					</td>
					<td>
						@if (item.NextVisitDate.HasValue)
						{
							<text>@item.NextVisitDate.Value.ToString("yyyy-MM-dd")</text>
						}
					</td>
					<td>
						@item.VisitDate
					</td>
					<td>
						@item.VisitDuration
					</td>
					<td>
						@item.CreateDate
					</td>
					<td>
						<a href="/Z30Communication/Edit/@item.CommunicationID?customerID=@item.CustomerID&ReturnUrl=@Request.RawUrl">修改</a> <a href='javascript:;' rel="@item.CommunicationID" class="xdel">
							删除</a> <a href='javascript:;' rel="@item.CommunicationID" class="xdetail">详情</a>
					</td>
				</tr>
				
				}
			}
			else
			{ 
				<!-- 没有数据的时候显示 -->
				<tr rel="item">
					<td colspan="100" class="msg-box h200">
						没有任何数据
					</td>
				</tr>
				<!-- 没有数据的时候显示 -->
			}
		</table>
	</div>
</div>
<div id="bottom">
	@Html.Raw(Model.ToPagerHtml("Z30Communication", "Index", Model.PageSize))
</div>
